package com.cyc.controller;

import com.cyc.entity.Address;
import com.cyc.entity.User;
import com.cyc.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("address")
public class AddressController {
    @Autowired
    private AddressService addressService;

    @RequestMapping("/all")
    public String all(Model model, String cost, HttpServletRequest request){
        User user = (User) request.getSession().getAttribute("user");
        List<Address> list = addressService.selectAllByUserId(user.getId());
        model.addAttribute("addressList",list);
        model.addAttribute("cost",cost);
        return "address";
    }
}
